KBI
 
Component KBI
Keyboard
Component Level: Low
Typical Usage:
(Examples of a typical usage of the component in user code. For more information please see the page Component Code Typical Usage.)

This component is typically used for connecting a keyboard via external pins of MCU. One of the typical usages of this component is connecting of the keys directly to pins. Suppose that three pins are added to the component Pin0 = 'KBI2', Pin1 = 'KBI1', Pin3 = 'KBI4' (any KBI pins can be assigned in any order). Further more assume that when a key is pressed, the corresponding pin value is log. 1.
  EVENTS.C

  bool keyPressed = false;
  byte key; 
   
  void KBI1_OnInterrupt(void) {
    keyPressed = true;     /* Key has been pressed */
    key = KBI1_GetVal();   /* Key code */
  }

  MAIN.C

  extern bool keyPressed;
  extern byte key;  

  void main(void) {
    
    :
  
    while(!keyPressed) {}  /* Wait until a key is pressed */    
    if(key & 0x01) {       /* Pin0 value is always in bit 0 of read value */
      /* A key on KBI2 was pressed */
    }
    if(key & 0x02) {       /* Pin1 value is always in bit 1 of read value */
      /* A key on KBI1 was pressed */
    }
    if(key & 0x04) {       /* Pin2 value is always in bit 2 of read value */
      /* A key on KBI4 was pressed */
    }
    if(key == 0x07) {      /* Are all (3) keys pressed at once ? */
      /* Yes all keys are pressed */
    }

    :
    
  }